package com.lineng.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.lineng.pojo.PartyBuilding;
import com.lineng.service.PartyBuildingService;

@Controller
public class PartyBuildingController {

	@Autowired
	PartyBuildingService partyBuildingService;

	/**
	 * 砺能先锋会内容
	 * 
	 * @return
	 */
	@RequestMapping(value = "/getPartyBuilding", method = RequestMethod.GET, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String getInnovation() {
		List<PartyBuilding> partybuildings = partyBuildingService.getPartybuilding();
		return JSON.toJSONString(partybuildings);

	}

	/**
	 * 砺能先锋会内容
	 * 
	 * @param partybuilding
	 * @param file
	 * @return
	 */
	@RequestMapping(value = "/updatePartyBuilding", method = RequestMethod.POST, produces = "text/json;charset=UTF-8")
	@ResponseBody
	public String updateInnovation(PartyBuilding partybuilding, MultipartFile file, HttpServletRequest request) {
		return JSON.toJSONString(partyBuildingService.updatePartybuilding(partybuilding, file,
				(String) request.getSession().getAttribute("username")));

	}

}
